<?php

class VehiculoController extends ControllerBase
{
	public function admin($array)
	{
		
		$data['nom_sistema'] = $array["nombre_sistema"];
		$data['controller'] = $array["controlador"];
						
		$data['arrayscriptJs'] = array("funcionesadmin.js");

		$this->view->show("admin/vehiculo.php", $data);
	}
	
	public function listaritemsadmin($array)
	{
		require 'models/VehiculoModel.php';
		$dato = new VehiculoModel();
		
		$_SESSION["f_patente"] = $array["patente"];
		$_SESSION["f_empresa"] = $array["empresa"];
		$data['controller'] = $array["controlador"];
		$data['result'] = $dato->getListaVehiculo($array);
		$data['inicio'] = $array["inicio"];
		$data['inicio_pag'] = $array["inicio_pag"];
	
		$this->view->show("admin/lista_vehiculo.php", $data);
	}
	
	public function alta($array)
	{	
		$data['nom_sistema'] = $array["nombre_sistema"];
		$data['controller'] = $array["controlador"];
		$data['tipop'] = $array["A"];
		$data['arrayscriptJs'] = array("validacampos.js","vehiculo_form.js","autocompletar/jquery/ui/jquery.ui.core.js","autocompletar/jquery/ui/jquery.ui.widget.js","autocompletar/jquery/ui/jquery.ui.position.js","autocompletar/jquery/ui/jquery.ui.autocomplete.js","jquery-ui-1.8.16.custom.min.js","jquery-ui-timepicker-addon.js","i18n/jquery.ui.datepicker-es.js","jquery-ui-sliderAccess.js");
		$data['arrayscriptCss'] = array("autocompletar/jquery/themes/base/jquery.ui.all.css","smoothness/jquery-ui-1.8.17.custom.css");

		$this->view->show("form/vehiculo.php", $data);
	}
	
	public function grabar_form($array)
	{
		require 'models/VehiculoModel.php';
		$dato = new VehiculoModel();
		
		$dato->grabar_datosVehiculo($array);
		
		$data['nom_sistema'] = $array["nombre_sistema"];
		$data['controller'] = $array["controlador"];
		$data['arrayscriptJs'] = array("funcionesadmin.js");
	
		redir("index.php?controlador=".$array["controlador"]."&accion=admin");
	}
	
	public function editar($array)
	{
		require 'models/VehiculoModel.php';
		require 'models/EmpresaModel.php';
		require 'models/PolizaSeguroModel.php';
		$dato = new VehiculoModel();
		$empresa = new EmpresaModel();
		$poliza = new PolizaSeguroModel();
		$vehiculo = $dato->getVehiculo($array);
		$data['nom_sistema'] = $array["nombre_sistema"];
		$data['controller'] = $array["controlador"];
		$data['tipop'] = "M";
		$data['dato'] = $vehiculo; 
		$data['empresa'] = $empresa->getEmpresa(array("id"=>$vehiculo->get_data("id_empresa")));
		$data['poliza_seguro'] = $poliza->getPolizaSeguro(array("id"=>$vehiculo->get_data("id_poliza_seguro")));
		$data['arrayscriptJs'] = array("validacampos.js","vehiculo_form.js","autocompletar/jquery/ui/jquery.ui.core.js","autocompletar/jquery/ui/jquery.ui.widget.js","autocompletar/jquery/ui/jquery.ui.position.js","autocompletar/jquery/ui/jquery.ui.autocomplete.js","jquery-ui-1.8.16.custom.min.js","jquery-ui-timepicker-addon.js","i18n/jquery.ui.datepicker-es.js","jquery-ui-sliderAccess.js");
		$data['arrayscriptCss'] = array("autocompletar/jquery/themes/base/jquery.ui.all.css","smoothness/jquery-ui-1.8.17.custom.css");

		
		$this->view->show("form/vehiculo.php", $data);
	}
	
	public function baja($array)
	{
		require 'models/VehiculoModel.php';
		
		$dato = new VehiculoModel();
		$dato->bajaVehiculo($array);
	}
}
?>